package com.simpleaccount.User;

import android.widget.Toast;

import com.simpleaccount.Toast.TextApplication;

import cn.bmob.v3.BmobUser;
import cn.bmob.v3.exception.BmobException;
import cn.bmob.v3.listener.FetchUserInfoListener;

/**
 * Created by zhou on 2017/7/17.
 * 更新用户信息，
 * 适用于登录后web端有更新，
 * 需要先登录，否则会报9024错误
 *
 *     !!!此方法从V3.5.6开始提供！！！
 */

public class FetchUserInfo {//class
      public void fetch_user_info(){//fetch_user_info
          AppUser appUser= BmobUser.getCurrentUser(AppUser.class);
          if(appUser!=null){//if appuser !=null
              AppUser.fetchUserInfo(new FetchUserInfoListener<AppUser>() {//fetch user info
                  @Override
                  public void done(AppUser appUser, BmobException e) {//done
                 if(e==null){
                    //显示更新后的信息
                     Toast.makeText(TextApplication.getAppContext(),"信息获取成功",Toast.LENGTH_SHORT).show();
                 }
                 else{
                     //提示更新错误
                     Toast.makeText(TextApplication.getAppContext(),"信息获取失败",Toast.LENGTH_SHORT).show();
                 }
                  }//done
              });//fetch user info
          }//if appuser !=null
          else{//else
          Toast.makeText(TextApplication.getAppContext(),"未登录，请先登录",Toast.LENGTH_SHORT).show();
          }//else


    }//fetch_user_info

}//class
